<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
      v-model.trim="dataList"
      @keyup.enter="add"
    />
  </header>
</template>

<script>
export default {
  name: 'ToHeader',
  props: {},
  data() {
    return {
      dataList: '',
    }
  },
  methods: {
    add() {
      if (this.dataList.length === 0) return

      this.$emit('add', this.dataList)
      this.dataList = ''
    },
  },
}
</script>

<style scoped lang="less"></style>
